# -*-* encoding:UTF-8 -*-
# author            : mengy
# date              : 2019/2/19
# python-version    : Python 3.7.0
# description       : Controller启动类

import os, redis
from flask import Flask
from flask_session import Session
from com.articles.microapp.utils.constants import CommonConstants
from com.articles.microapp.config.config import CONFIG

from com.articles.microapp.controller.app_controller import WechatInterface
from com.articles.microapp.controller.article_controller import ArticleController
from com.articles.microapp.controller.remark_controller import RemarkController

if __name__ == '__main__':
    consts = CommonConstants()
    config = CONFIG.config()

    # 设置SECRET_KEY
    SECRET_KEY = os.urandom(36)

    app = Flask(__name__)
    # 关闭ascii编码，支持中文
    app.config['JSON_AS_ASCII'] = False
    # session 存入redis缓存
    # app.config['SECRET_KEY'] = SECRET_KEY
    # app.config['SESSION_TYPE'] = 'redis'
    # app.config['SESSION_REDIS'] = redis.Redis(host=config.get_value(consts.CACHE_SECTION, consts.CACHE_HOST),
    #                                           port=int(config.get_value(consts.CACHE_SECTION, consts.CACHE_PORT)))
    Session(app)
    wechat = WechatInterface(app)
    article = ArticleController(app)
    remark = RemarkController(app)
    app.run(host='localhost', port='5000')
